

window.onresize = resizeApp;
window.onload = on_load;

/**
 * This function return the size of the window
 */
function getWindowSize()
{
	 var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	  }

	return {'height':myHeight,'width':myWidth}
}

function resizeApp()
{
	size = getWindowSize();
	resize_toolbar(size);
	resize_query(size);
	resize_result(size);
	resize_horizontal_slider(size);
	resize_vertical_slider(size);
	resize_navigation(size);
}

function on_load()
{
	new Draggable('horizontal_slider',{constraint:'vertical',
				  onEnd: function(){
						  query_height= $('horizontal_slider').getStripStyle('top') - $('query').getStripStyle('top');
					 	 $('query').setStyle({'height': (query_height)+'px'});	
						  result_top = Number($('horizontal_slider').getStripStyle('top')) + Number($('horizontal_slider').getStripStyle('height'));
						  $('result').setStyle({'top': (result_top)+'px'});	
							resize_result(size);
							resize_query(size);							
					  }					  
				  });
	new Draggable('vertical_slider',{constraint:'horizontal',
			  onEnd: function(){
					  left_distance = Number($('vertical_slider').getStripStyle('left'))+10;
					 $('query').setStyle({'left': (left_distance)+'px'});	
 					 $('result').setStyle({'left': (left_distance)+'px'});	
					 $('horizontal_slider').setStyle({'left': (left_distance)+'px'});						 
					  $('navigation').setStyle({'width': (Number(left_distance)-10)+'px'});	
						resize_result(size);
						resize_query(size);	
						resize_horizontal_slider(size);						
				  }					  
			  });	
	resizeApp();
}


String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function is_array( mixed_var ) {
    return ( mixed_var instanceof Array );
}
